package com.huan.ddl;

import com.huan.Call;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;

import java.io.IOException;

public class DelTableAPI {


    //删除表
    public static void dropTable(String tableName) throws IOException {

        //1.判断表是否存在
        if (!NewTestAPI.isTableExist( tableName )){
            System.out.println(tableName + "表不存在");
            return;
        }


        //2.使表下线
        Admin admin = Call.admin;
        admin.disableTable( TableName.valueOf( tableName ) );

        //3.删除表
        admin.deleteTable( TableName.valueOf( tableName ) );
    }


    public static void main(String[] args) throws IOException {

        dropTable( "fruit" );

        Call.close();
    }
}
